-
-
Notifications
You must be signed in to change notification settings - Fork 398
[breaking] daemon: Fix concurrency and streamline access to PackageManager #1828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[breaking] daemon: Fix concurrency and streamline access to PackageManager #1828
Conversation
e4ed93a
to
de6ae8c
Compare
Codecov Report
@@ Coverage Diff @@
## daemon-fixes #1828 +/- ##
================================================
- Coverage 36.47% 36.33% -0.14%
================================================
Files 232 231 -1
Lines 19401 19550 +149
================================================
+ Hits 7076 7103 +27
- Misses 11500 11617 +117
- Partials 825 830 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Ref: arduino/arduino-cli#1828 Signed-off-by: Akos Kitta <[email protected]>
Ref: arduino/arduino-cli#1828 Signed-off-by: Akos Kitta <[email protected]>
Ref: arduino/arduino-cli#1828 Signed-off-by: Akos Kitta <[email protected]>
It has been splitted and merged into HardwareLoader and TargetBoardResolver that are more appropriate.
de6ae8c
to
6e00737
Compare
This PR now targets arduino:daemon-fixes branch, the docs will be updated later or in another PR. |
} | ||
|
||
pm := pmb.Build() | ||
pme, _ /* never release... */ := pm.NewExplorer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is really ugly, maybe bringing this inside the arduino builder should solve the problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it's more complicated than that, we have to keep it for now.
Let's open a dedicated issue to keep track of it and fix it in the future.
They have been moved into a Builder object that has the ability to build a new PackageManager. This allows to clearly separate subrotuines that actually change the status of the PackageManager from subroutines that just need to query it.
The Explorer object can be see as a read-only "view" to the underlying PackageManager: we may ask the PackageManager to create an Explorer on itself. The returned explorer will held a read-lock on the PackageManager until it's disposed. This architecture should prevent unwanted changes on the PackageManager while it's being used, and viceversa, when the PackageManager is updated it should be guaranteed that no Explorers are reading it.
7ed5863
to
721e407
Compare
… calling commands.Init Otherwise, since Init will try to take a write-lock, it will block indefinitely.
This container will handle all the atomic access to the instances map.
It has also been deprecated in favor of GetPackageManagerExplorer.
Previuosly the methods PackageManager.NewBuilder and PackageManager.NewExplorer were available also on Builder and Explorer. Now Builder and Explorer does not inherith these methods anymore, avoiding trivial errors like the one fixed in this commit in the builder_utils package.
249193a
to
23694ca
Compare
23694ca
to
04e70c5
Compare
45844a8
to
afbed02
Compare
Co-authored-by: per1234 <[email protected]>
009dc94
to
df28c7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I verified that the recent round of changes fixed the known defect in the IDE that occurred when using the previous version: arduino/arduino-ide#1330
I have also done a lot of general testing of the Arduino IDE 2.x integration without discovering any problems.
Thanks for your excellent work both on the code and the documentation Cristian!
Please check if the PR fulfills these requirements
before creating one)
our contributing guidelines
UPGRADING.md
has been updated with a migration guide (for breaking changes)Makes access to PackageManger thread-safe and transactional allowing multiple thread concurrent access.
This is not a problem when the arduino-cli is run from the command line (since there is no concurrency in this case), but it can be problematic in daemon mode, when a thread may read the package manager status while another one is writing on it (for example a thread may do a
BoardSearch
while another one is doing aPlatformsInstall
or anInit
).The CLI daemon may crash in some specific circumstances.
The CLI daemon should handle gracefully any combination of gRPC requests.
Yes, docs are
not yetupdated.This PR is built on top of Fix gRPC
BoardList*
methods concurrency issues #1804 and must be merged together with it.